package gaobo;

class Food{

}
class Fruit extends Food{

}
class Apple extends Fruit{

}
class Banana extends Fruit{

}

class Plate<T>{//设置泛型 shift+f6
    private T plate;

    public T getPlate(){
        return plate;
    }
    public void setPlate(T plate){
        this.plate = plate;
    }
}

public class Test {
    public static void main(String[] args) {
        Plate<Apple> plate1 = new Plate<>();
        plate1.setPlate(new Apple());
        fun(plate1);

        Plate<Banana> plate2 = new Plate<>();
        plate2.setPlate(new Banana());
        fun(plate2);
    }

    public static void fun(Plate<? extends Fruit> temp){
        Fruit fruit = temp.getPlate();
        System.out.println(temp.getPlate());
    }
}
